package com.atguigu.gmallre.mock.log;


import com.atguigu.gmallre.mock.config.AppConfig;
import com.atguigu.mock.util.RanOpt;
import com.atguigu.mock.util.RandomBox;
import com.atguigu.mock.util.RandomNum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

@Data
@AllArgsConstructor
@Builder(builderClassName = "Builder")
public class AppCommon {

    private String mid; // (String) 设备唯一标识
    private String uid; // (String) 用户uid
    private String sid; //  (String) sessionId
    private String vc;  // (String) versionCode，程序版本号
    private String ch;  // (String) 渠道号，应用从哪个渠道来的。
    private String os;  // (String) 系统版本
    private String ar;  // (String) 区域
    private String md;  // (String) 手机型号
    private String ba;  // (String) 手机品牌
    private String is_new; // 是否新用户


   public  static AppCommon build(   ){
         String mid; // (String) 设备唯一标识
         String uid; // (String) 用户uid
         String sid=null; //  (String) sessionId
         String vc;  // (String) versionCode，程序版本号
         String ch;  // (String) 渠道号，应用从哪个渠道来的。
         String os;  // (String) 系统版本
         String ar;  // (String) 区域
         String md;  // (String) 手机型号
         String ba;  // (String) 手机品牌
         String isnew;

        mid="mid_"+RandomNum.getRandInt(1, AppConfig.max_mid)+"";;

        ar = String.valueOf( RandomNum.getRandInt(1,34));

       md = new RandomBox<String>(new RanOpt<String>("xiaomi 13", 10),
               new RanOpt<String>("xiaomi 13 Pro ", 10),
               new RanOpt<String>("xiaomi 12 ultra ", 20),
               new RanOpt<String>("iPhone 14", 30),
               new RanOpt<String>("iPhone 13", 20),
               new RanOpt<String>("vivo x90", 20),
               new RanOpt<String>("iPhone 14 Plus", 20),
               new RanOpt<String>("vivo IQOO Z6x ", 10),
               new RanOpt<String>("OPPO Remo8", 10),
               new RanOpt<String>("Redmi k50", 20),
               new RanOpt<String>("SAMSUNG Galaxy s22", 5),
               new RanOpt<String>("realme Neo2", 20),
               new RanOpt<String>("OPPO Oneplus 10", 5),
               new RanOpt<String>("SAMSUNG Galaxy S21", 3)).getRandStringValue();

       ba = md.split(" ")[0];

       if(ba.equals("iPhone")){
           ch="Appstore";
           os ="iOS "+ new RandomBox<String>(new RanOpt<String>("13.3.1", 30),
                   new RanOpt<String>("13.2.9", 10),
                   new RanOpt<String>("13.2.3", 10),
                   new RanOpt<String>("12.4.1", 5)
           ).getRandStringValue();

       }else{
           ch = new RandomBox<String>(new RanOpt<String>("xiaomi", 30),
                   new RanOpt<String>("wandoujia", 10),
                   new RanOpt<String>("web", 10),
                   new RanOpt<String>("oppo", 20),
                   new RanOpt<String>("vivo", 5),
                   new RanOpt<String>("360", 5)
           ).getRandStringValue();
           os="Android "+ new RandomBox<String>(new RanOpt<String>("13.0", 70),
                   new RanOpt<String>("12.0", 20),
                   new RanOpt<String>("11.0", 5),
                   new RanOpt<String>("10.1", 5)
           ).getRandStringValue();
       }

       vc="v"+ new RandomBox<String>(new RanOpt<String>("2.1.134", 70),
               new RanOpt<String>("2.1.132", 20),
               new RanOpt<String>("2.1.111", 5),
               new RanOpt<String>("2.0.1", 5)
       ).getRandStringValue();

        uid= null;

       isnew= RandomNum.getRandInt(0,1)+"";

       AppCommon appBase = new AppCommon(mid, uid,sid, vc, ch, os, ar, md, ba ,isnew );
       return appBase;
   }

    public static void main(String[] args) {
        Builder builder = AppCommon.builder();
    }



}
